import { injectable } from 'tsyringe';
import type { IMessageRepository } from '../../domain/interfaces/IMessageRepository';

@injectable()
export class MessageRepository implements IMessageRepository {
  private store: any[] = [];

  async save(message: any): Promise<void> {
    this.store.push(message);
  }

  async findByRoom(roomId: string, limit: number = 50): Promise<any[]> {
    return this.store.filter((m) => m.roomId === roomId).slice(-limit);
  }
}
